package ItemBased;


import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;


public class LongDoublePairWritable implements WritableComparable<LongDoublePairWritable>{

    /**
     * the first field
     */
    long first;

    /**
     * the second field
     */
    double second;

    public LongDoublePairWritable() {

    }

    public LongDoublePairWritable(long t1, double t2) {
    	first = t1;
    	second = t2;
    }
   
 /*   
    public void setFirstText(String t1) {
            first.set(Long.parseLong(t1));
    }
   
    
    public void setSecondText(String t2) {
            second.set(Double.parseDouble(t2));
    }

    
    public LongWritable getFirst() {
            return first;
    }

    
    public DoubleWritable getSecond() {
            return second;
    }
*/
    public LongDoublePairWritable get() {
        return this;
    }
    public void write(DataOutput out) throws IOException {
            out.writeLong(first);
            out.writeDouble(second);
    }

    public void readFields(DataInput in) throws IOException {
            first = in.readLong();

            second = in.readDouble();
    }

    public int compareTo(LongDoublePairWritable ip2) {
    	long thisValue = this.first;
        long thatValue = ip2.first;
        return (thisValue < thatValue ? -1 : (thisValue == thatValue ? 0 : 1));
    }

    public int hashCode() {
            return (int) first;
    }
}


